import HttpAxios from "../../components/http/HttpAxios";

class UserService{

  baseUrl = process.env.POINT_SHOPPING_URL;
  authBaseUrl = process.env.AUTH_SERVICE_URL;
  pointBaseUrl = process.env.POINT_SERVICE_URL;
  httpClient= new HttpAxios();




  queryListUtl="/point-shopping/goods/list";
  queryUserOrderUrl = "/point-shopping/goods-order/list";
  queryUserAllOrderUrl = "/point-shopping/goods-order/list-all";

  adminDeliverGoodsUrl = "/point-shopping/admin/goods/deliver-goods";
  adminFinishGoodsUrl = "/point-shopping/admin/goods/finish";
  adminWithdrawGoodsUrl ="/point-shopping/admin/goods/withdraw";

  queryAdminListUrl="/show/admin/all";
  enableAccountUrl="/enable/";
  disableAccountUrl="/disable/";
  queryUserInfoUrl = "/query/users/";

  clearPointsUrl="/points/users/reset";

  queryList(data,call){
    this.httpClient.post(this.baseUrl+this.queryListUtl,{},call);
  }

  queryUserInfo(username:string,token:string,call){
    this.httpClient.getAndToken(this.pointBaseUrl+this.queryUserInfoUrl+username,{},token,call);
  }


  queryUserOrder(data,token:string,callback){
    this.httpClient.getAndToken(this.baseUrl+this.queryUserOrderUrl,data,token,callback);
  }

  adminDeliverGoods(data,token:string,callback){
    this.httpClient.postAndToken(this.baseUrl+this.adminDeliverGoodsUrl,data,token,callback);
  }
  adminFinishGoods(data,token:string,callback){
    this.httpClient.postAndToken(this.baseUrl+this.adminFinishGoodsUrl,data,token,callback);
  }
  adminWithdrawGoods(data,token:string,callback){
    this.httpClient.postAndToken(this.baseUrl+this.adminWithdrawGoodsUrl,data,token,callback);
  }

  queryUserAllOrder(data,token:string,callback){
    this.httpClient.getAndToken(this.baseUrl+this.queryUserAllOrderUrl,data,token,callback);
  }

  queryAdminList(data,token,callback){
    this.httpClient.getAndToken(this.authBaseUrl+this.queryAdminListUrl,data,token,callback);

  }

  enableAccount(username:string,token:string,callback){
    this.httpClient.getAndToken(this.authBaseUrl+this.enableAccountUrl+username,{},token,callback);
  }

  disableAccount(username:string,token:string,callback){
    this.httpClient.getAndToken(this.authBaseUrl+this.disableAccountUrl+username,{},token,callback);
  }

  clearPoints(token:string,callback){
    this.httpClient.postAndToken(this.pointBaseUrl+this.clearPointsUrl,{},token,callback);
  }
}

export default UserService;
